<!--
	作者：weixin
	时间：2017-03-30
	描述：招聘管理页面
-->
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>招聘管理-后台管理系统</title>
		<link rel="stylesheet" href="${rc.contextPath}/bootstrap/css/bootstrap.css" />
		<link rel="stylesheet" href="${rc.contextPath}/zui/css/zui.css" />
		<script src="${rc.contextPath}/js/jquery.1.10.1.min.js"></script>
		<script type="text/javascript" src="${rc.contextPath}/zui/js/zui.js"></script>
	</head>

	<body>
		<ul class="nav nav-tabs" id="adminTab">
			<li>
				<a href="index.html" data-togggle="tab">首页</a>
			</li>
			<li class="active">
				<a href="erterprise_manage.html" data-togggle="tab">企业管理及审核</a>
			</li>
			<li>
				<a href="forum_manage.html" data-togggle="tab">论坛管理</a>
			</li>
			<li>
				<a href="message.html" data-togggle="tab">消息</a>
			</li>
			<li class="pull-right">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown">
					<img src="${rc.contextPath}/img/leader_default.png" width="20px" />管理员<span class="caret"></span>
				</a>
				<ul class="dropdown-menu">
					<li>
						<a href="#">账号设置</a>
					</li>
					<li>
						<a href="#">退出</a>
					</li>
				</ul>
			</li>
		</ul>

		<!--  左侧菜单  -->
		<div style="margin-top: 20px;" class="col-xs-2">
			<nav class="menu" data-toggle="menu" style="width: 200px;">
				<ul class="nav nav-primary">

					<li class="active show nav-parent">
						<a href="javascript:;"><i class="icon icon-group"></i> 公司</a>
						<ul class="nav">
							<li>
								<a href="enterprise_manage.html"><i class="icon icon-cog"></i> 公司信息管理</a>
							</li>
							<li>
								<a href="enterprise_check.html">
									<i class="icon icon-trophy"></i> 公司认证审核<span class="label label-badge pull-right">5</span>
								</a>
							</li>
							<li>
								<a href="javascript:;" ><i class="icon icon-plus"></i> 添加公司</a>
							</li>
						</ul>
					</li>

					<li class="active show nav-parent">
						<a href="javascript:;"><i class="icon icon-book"></i> 招聘</a>
						<ul class="nav">
							<li class="active">
								<a href="job_manage.html"><i class="icon icon-list-ul"></i> 招聘管理</a>
							</li>
							<li>
								<a href="javascript:;"><i class="icon icon-pencil"></i> 发布招聘</a>
							</li>
						</ul>
					</li>
				</ul>
			</nav>
		</div>

		<div class="col-xs-8" style="margin-top: 20px;">
			<div class="panel">
				<form action="${rc.contextPath}/admin/searchproduct" method="get">
					<div class="panel-body">
						<div class="col-xs-2">
							<select name="searchtype" class="form-control">
								<option value="0" selected="selected">职位名称</option>
								<!-- <option value="1">公司所在地</option> -->
							</select>
						</div>
						<div class="col-xs-6">
							<input type="text" class="form-control" name="keyword" />
						</div>
						<div class="col-xs-4">
							<input type="submit" class="btn btn-primary" value="搜索职位" />
							<input type="button" class="btn btn-primary" value="显示今日新增职位" />
						</div>
						<input type="hidden" value="$!keyword" id="searchctx"/>
					</div>
				</form>
			</div>

			<table class="table table-striped">
				<thead>
					<tr>
						<th width="40%">职位名称</th>
						<th>工作城市</th>
						<th>所属公司</th>
						<th>工作性质</th>
						<th>月薪</th>
						<th>发布人</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
				#foreach($!job in $!jobList)
					<tr>
						<td>
							<a href="${rc.contextPath}/job/detail/$!job.id">$!job.job_name</a>
						</td>
						<td>$!job.location_name</td>
						<td>$!job.job_company_name</td>
						#if($!job.job_category == 0)
						<td>全职</td>
						#end
						#if($!job.job_category == 1)
						<td>兼职</td>
						#end
						#if($!job.job_category == 2)
						<td>实习</td>
						#end
						<td>$!{job.job_salary_min}K~$!{job.job_salary_max}K</td>
						<td>$!job.creater_name</td>
						<td>
							<a href="#" data-toggle="modal" data-target="#editJob" data-id="$!job.id">修改</a>&nbsp;|&nbsp;
							<button type="button" class="btn btn-mini unload" data-id="$!job.id">删除</button> &nbsp;|&nbsp;
						</td>
					</tr>
				#end
				</tbody>
			</table>
			
			<div class="pagination" style="margin: 0px 0 20px;">$!page.pageString</div>

		</div>


		<!---------------------------------- 修改招聘弹出对话框  ------------------------------------->
		<div class="modal fade" id="editJob">
			<div class="modal-dialog">
				<form class="form-horizontal" action="#" id="editJobForm" method="post">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
						<h4 class="modal-title">修改职位信息</h4>
					</div>
					<div class="modal-body">
						
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">职位行业</label>
							<div class="col-md-6 col-sm-10">
								<select class="form-control" id="job_domain_id" name="job.job_domain_id">
									#foreach($!domain in $!domainList)
									<option value="$!domain.id">$!domain.domain_name</option>
									#end
								</select>
							</div>
							</div>
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">职位名称</label>
								<div class="col-md-6 col-sm-10">
									<input type="hidden" name="job.id"/>
									<input type="text" class="form-control" id="job_name" name="job.job_name" placeholder="请输入职位名称"/>
								</div>
							</div>
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">所属部门</label>
								<div class="col-md-6 col-sm-10">
									<input type="text" class="form-control" id="job_department" name="job.job_department" placeholder="所属部门，可不填"/>
								</div>
							</div>
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">工作性质</label>
								<div class="col-md-6 col-sm-10">
									<select class="form-control" id="job_category" name="job.job_category">
										<option value="0">全职</option>
										<option value="1">兼职</option>
										<option value="2">实习</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">月薪范围</label>
								<div class="col-md-6 col-sm-10">
									<input type="number" class="form-control" id="job_salary_min" name="job.job_salary_min" placeholder="月薪下限"/>k
									~
									<input type="number" class="form-control" id="job_salary_max" name="job.job_salary_max" placeholder="月薪上限"/>k
								</div>
							</div>
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">工作城市</label>
								<div class="col-md-6 col-sm-10">
									<input type="number" class="form-control" id="job_location" name="job.job_location" placeholder="工作城市"/>
								</div>
							</div>
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">工作经验</label>
								<div class="col-md-6 col-sm-10">
									<select class="form-control" id="job_request_worktime" name="job.job_request_worktime">
										<option value="0">不限</option>
										<option value="1">应届毕业生</option>
										<option value="2">1年以下</option>
										<option value="3">1-3年</option>
										<option value="4">3-5年</option>
										<option value="5">5-10年</option>
										<option value="6">10年以上</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">学历要求</label>
								<div class="col-md-6 col-sm-10">
									<select class="form-control" id="job_request_edubackground" name="job.job_request_edubackground">
										<option value="0">不限</option>
										<option value="1">大专</option>
										<option value="2">本科</option>
										<option value="3">硕士</option>
										<option value="4">博士</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">职位诱惑</label>
								<div class="col-md-6 col-sm-10">
									<textarea  class="form-control" id="job_request_brief" name="job.job_request_brief" placeholder="请输入职位简介"></textarea>
								</div>
							</div>
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">职位详情描述</label>
								<div class="col-md-6 col-sm-10">
									<input type="hidden" name="jobDetail.id"/>
									<textarea  class="form-control" id="request_content" name="jobDetail.request_content" placeholder="请输入职位详情描述"></textarea>
								</div>
							</div>
							<div class="form-group">
								<label for="exampleInputAccount4" class="col-sm-2">接收简历邮箱</label>
								<div class="col-md-6 col-sm-10">
									<input type="email" class="form-control" id="job_receive_email" name="job.job_receive_email" placeholder="请输入职接收简历邮箱"/>
								</div>
							</div>
						
					</div>

					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						<button type="reset" style="display: none;">重置</button>
						<button type="button" class="btn btn-primary" data-id="$!job.id" id="update">保存</button>
					</div>
				</div>
				</form>
			</div>
		</div>
		<!--------------------------------------- end  ------------------------------------------------>

	</body>
	<script type="text/javascript">
	$('#editJob').on('show.zui.modal', function (e) {
		console.log("aa");
		jQuery.getJSON("${rc.contextPath}/job/queryJob?id="+$(e.relatedTarget).data("id"),function(data){
			$("input[name='job.id']").val(data.job.id);
			$("select[name='job.job_domain_id']").val(data.job.job_domain_id);
			$("input[name='jobDetail.id']").val(data.jobDetail.id);
			$("input[name='job.job_name']").val(data.job.job_name);
			$("input[name='job.job_department']").val(data.job.job_department);
			$("select[name='job.job_category']").val(data.job.job_category);
			$("select[name='job.job_request_worktime']").val(data.job.job_request_worktime);
			$("select[name='job.job_request_edubackground']").val(data.job.job_request_edubackground);
			$("input[name='job.job_salary_min']").val(data.job.job_salary_min);
			$("input[name='job.job_salary_max']").val(data.job.job_salary_max);
			$("input[name='job.job_location']").val(data.job.job_location);
			$("textarea[name='job.job_request_brief']").val(data.job.job_request_brief);
			$("textarea[name='jobDetail.request_content']").val(data.jobDetail.request_content);
			$("input[name='jobDetail.id']").val(data.jobDetail.id);
			$("input[name='job.job_receive_email']").val(data.job.job_receive_email);
		});
	});
	$("#editJob").on('hide.zui.modal',function(e){
		$("button[type='reset']").trigger("click");
	});
	$("#update").click(function(){
		jQuery.post("${rc.contextPath}/job/updateJob", $("#editJobForm").serialize(), function(data) {
				(new jQuery.zui.ModalTrigger({
					custom : data.info
				})).show({hidden: function(){
					if(data.code == 200){
						location.reload();
						//window.location.href = "${rc.contextPath}/admin/addcompany";
					}
				}});
		}, 'json');
	});
	$(".unload").click(function(){
		if(confirm("是不是确认删除咯？")){
			jQuery.getJSON('${rc.contextPath}/job/deleteJob?id='+$(this).data("id"),function(data){
				if(data.code == 200){
					(new jQuery.zui.ModalTrigger({
						custom : data.info
					})).show({hidden: function(){
						location.reload();
					}});
				}else{
					(new jQuery.zui.ModalTrigger({
						custom : data.info
					})).show();
				}
			})
		}
	});
	
	$(document)
	.on(
			"click",
			".pagination a",
			function(e) {
				var pageNum = $(this).attr("pageData");
				if (pageNum == 0 || isNaN(pageNum)) {
					return;
				}
				var sctx = $("#searchctx").val();
				if(sctx!=null){
					window.location.href = "${rc.contextPath}/admin/searchjob/"+ pageNum +"?keyword="+sctx;
				}
				window.location.href = "${rc.contextPath}/admin/job_manage/"+ pageNum;
			});
	</script>

</html>